﻿/* 
 * Copyright (c) 2009 Intel Corporation
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * -- Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * -- Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * -- Neither the name of the Intel Corporation nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE INTEL OR ITS
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

using System;

namespace VerseSharp
{
    public static class VerseConstants
    {
        public static byte VERSE_VERSION = 6;

        public static int PACKET_BUFFER_SIZE = 1500;
        public static int MAXIMUM_COMMANDS = 256;

        public static int ENCRYPTION_KEY_BITS = 512;
        public static int ENCRYPTION_KEY_SIZE = ENCRYPTION_KEY_BITS / 8;

        public static int ENCRYPTION_LOGIN_KEY_FULL_SIZE = 3 * ENCRYPTION_KEY_SIZE;
        public static int ENCRYPTION_LOGIN_KEY_HALF_SIZE = 2 * ENCRYPTION_KEY_SIZE;
        
        public static int ENCRYPTION_LOGIN_PUBLIC_START =  0 * ENCRYPTION_KEY_SIZE;
        public static int ENCRYPTION_LOGIN_PRIVATE_START = 1 * ENCRYPTION_KEY_SIZE;
        public static int ENCRYPTION_LOGIN_N_START =       2 * ENCRYPTION_KEY_SIZE;

		public static NodeTypes AllNodeTypes = NodeTypes.Audio | NodeTypes.Bitmap | NodeTypes.Curve | NodeTypes.Geometry | NodeTypes.Material | NodeTypes.Object | NodeTypes.Text;
    }

    public enum NodeType : byte
    {
        Object = 0,
        Geometry ,
        Material,
        Bitmap,
        Text,
        Curve,
        Audio,
    }

    public enum NodeOwner : byte
    {
        Other = 0,
        Mine = 1,
    }

    public enum RealFormat : byte
    {
        Real32 = 0,
        Real64 = 1,
    }

    public enum LayerType : byte
    {
        VertexXYZ = 0,
        VertexUInt32 = 1,
        VertexReal = 2,
        PolygonCornerUInt32 = 128,
        PolygonCornerReal = 129,
        PolygonFaceUInt8 = 130,
        PolygonFaceUInt32 = 131,
        PolygonFaceReal = 132,
    }

    [Flags]
    public enum NodeTypes : uint
    {
        Object = 1,
        Geometry = 2,
        Material = 4,
        Bitmap = 8,
        Text = 16,
        Curve = 32,
        Audio = 64,
    }

    public enum CommandID : byte
    {
        Connect = 0,
        ConnectAccept = 1,
		ConnectTerminate = 2, // Note: spec says 3, ref implementation uses 2. http://verse.blender.org/fileadmin/verse/spec/connect_terminate.html
        Ping = 5,
        PacketAck = 7,
        PacketNak = 8,
        NodeIndexSubscribe = 9,
        NodeCreate = 10,
        NodeSubscribe = 11,
        NodeNameSet = 19,

        TagGroupCreate = 16,
        TagGroupSubscribe = 17,
        TagCreate = 18,

        ObjectTransformPosReal32 = 32,
        ObjectTransformRotReal32 = 33,
        ObjectTransformScaleReal32 = 34,
        ObjectTransformPosReal64 = 35,
        ObjectTransformRotReal64 = 36,
        ObjectTransformScaleReal64 = 37,
        ObjectTransformSubscribe = 38,

        ObjectLightSet = 39,
        ObjectLinkSet = 40,

        ObjectMethodGroupCreate = 41,
        ObjectMethodGroupSubscribe = 42,
        ObjectMethodCreate = 43,
        ObjectMethodCall = 44,

        ObjectAnimRun = 45,
        ObjectHide = 46,

        GeometryLayerCreate = 48,
        GeometryLayerSubscribe = 49,
        GeometryVertexSetXYZReal32 = 50,
        GeometryPolygonSetCornerUInt32 = 55,
        GeometryCreaseSetVertex = 62,
        GeometryCreaseSetEdge = 63,
    }

	public enum ParamType : byte
	{
		Int8 = 0,
		Int16,
		Int32,
		Uint8,
		Uint16,
		Uint32,
		Real32,
		Real64,
		String,
		Node,
		Layer,
		Real32Vec2,
		Real32Vec3,
		Real32Vec4,
		Real64Vec2,
		Real64Vec3,
		Real64Vec4,
		Real32Mat4,
		Real32Mat9,
		Real32Mat16,
		Real64Mat4,
		Real64Mat9,
		Real64Mat16,
	}
}
